<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数组练习2</title>
</head>
<body>
<!--
  2.将数组[4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0]中的0项去掉，将不为0的值存入一个新的数组
-->

<script>

    var arr = [4, 0, 7, 9, 0, 0, 2, 6, 0, 3, 1, 0]

    var newArray = []

    for (var i = 0; i < arr.length; i++) {

        if (arr[i]) {
            newArray.push(arr[i])
        }
    }

    console.log(newArray)

</script>
</body>
</html>